from django.db import models

# Create your models here.
# post_id: 字符串，唯一标识文章
# title: 字符串，文章标题
# content: 文本，文章内容
# author_name: 字符串，作者姓名
# is_published: 布尔值，文章是否发布
# publish_date: 日期时间，文章发布时间
class User(models.Model):
    username = models.CharField(max_length=64, verbose_name='用户名')
    password = models.CharField(max_length=64, verbose_name='密码')

class Author(models.Model):
    genderlist = [('boy', '男'), ('girl', '女')]
    author = models.CharField(max_length=64, verbose_name='作者')
    address = models.CharField(max_length=64, verbose_name='地址')
    age = models.IntegerField(verbose_name='年龄')
    gender = models.CharField(choices=genderlist, verbose_name='性别')

class BlogPost(models.Model):
    post_id = models.IntegerField(unique=True)
    title = models.CharField(max_length=32, verbose_name='文章标题')
    content = models.TextField(verbose_name='文章内容')
    author_info = models.ForeignKey(Author,on_delete=models.CASCADE,related_name='Authorinfo', verbose_name='作者信息')
    is_published = models.BooleanField(verbose_name='文章是否发布')
    publish_date = models.DateTimeField(auto_now_add=True,verbose_name='文章发布时间')

class Student(models.Model):
    name = models.CharField(max_length=32,unique=True)
    age = models.IntegerField()
class course(models.Model):
    classname = models.CharField(max_length=32,unique=True)
    classtime = models.IntegerField()
    student = models.ManyToManyField(Student,related_name='course')

# post_id,title,content,author_info,is_published,publish_date






